<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .a {
        font-size: 3rem;
      }
      .b {
        color: red;
      }
      .c {
        border: solid;
      }
      .d {
        text-decoration: underline;
      }
      .e {
        background: yellow;
      }
    </style>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <h2 class="a b c">hello title</h2>

        <h2 :class="[activeA?'a':'','b',activeC?'c':'','d','e']">
          hello title
        </h2>
        <h2 :class="clsArr">hello title</h2>
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      // 数据驱动视图
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          clsArr: ["a", "b", "c"],
          activeA: true,
          activeC: true,
        },
        created() {
          setTimeout(() => {
            this.activeA = false;
            this.activeC = false;
            // this.clsArr.pop();
            this.clsArr.splice(1, 2, "d", "e");
          }, 3000);
        },
      });
    </script>
  </body>
</html>
